﻿using IntelligentAgriculture.Contracts.Dto.Output;
using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.WebAPI.Application.Command.PersonalDetailsCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.PersonalDetailsCommandHandler
{
    public class GetPersonalDetailsCommandHandler : IRequestHandler<GetPersonalDetailsCommand, Results<PersonalDetailsOutput>>
    {
        private readonly IPersonalSettingService _personalSettingService;

        public GetPersonalDetailsCommandHandler(IPersonalSettingService personalSettingService)
        {
            _personalSettingService = personalSettingService;
        }
        public async Task<Results<PersonalDetailsOutput>> Handle(GetPersonalDetailsCommand request, CancellationToken cancellationToken)
        {
            var details = _personalSettingService.GetPersonalDetails(request.UId);
            return Results<PersonalDetailsOutput>.DataResult(details);
        }
    }
}
